Component({
  mixins: [],
  data: {
    value: '',
    placeholder:'',
    dataList: []
  },
  props: {
    dataList: [],
    placeholder:'',
    value: "",
    onChange(v) {
      // console.log(v);
    },
  },
  didMount() {
    this.setData({ value: this.props.value, placeholder:this.props.placeholder })
  },
  didUpdate() { },
  didUnmount() { },
  methods: {
    handleValChange(e) {
      this.props.onChange(e.detail.value)
      this.setData({ value: e.detail.value })

      if (this.data.value.length > 0) {
        this.setData({ dataList: this.props.dataList.filter(it => it.includes(this.data.value)) })
      }
    },
    handleDataSelete(e) {
      const val = e.target.dataset.val
      this.props.onChange(val)
      this.setData({value:val, dataList:[]})
    }
  },
});
